package com.sky.yipinyoufujava.mapper;

import com.sky.yipinyoufujava.pojo.from.ShopsFrom;
import com.sky.yipinyoufujava.pojo.goods.*;
import com.sky.yipinyoufujava.pojo.from.GoodsForm;
import com.sky.yipinyoufujava.pojo.goodsType.FirstGoodsType;
import com.sky.yipinyoufujava.pojo.goodsType.SecondGoodsType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GoodsMapper {
    List<Goods> getGoods(GoodsForm goodsForm);

    void insertGoods(Goods goods);


    void updateGoods(Goods goods);


    void deleteGoods(@Param("ids") List<Short> ids);


    @Select("SELECT * FROM goods where id = #{goodsId};")
    Goods getGoodsInfo(Object goodsId);

    @Select("SELECT * FROM goodsPoster where goodsId = #{goodsId};")
    List<GoodsPoster> getGoodsPoster(Object goodsId);

    @Select("SELECT * FROM goodsImage where goodsId = #{goodsId};")
    List<GoodsImage> getGoodsImage(Object goodsId);


    @Select("SELECT * FROM goods where isExplosion = 1;")
    List<Goods> getExplosion();


    @Select("SELECT * FROM goods where isExplosion = 0;")
    List<Goods> getGoodsList();

    @Select("SELECT * FROM firstgoodstype;")
    List<FirstGoodsType> getFirstGoodsTypes();

    @Select("SELECT * FROM secondgoodstype where fatherId = #{id};")
    List<SecondGoodsType> SecondGoodsType(Integer id);


    @Select("SELECT s.* FROM Shops s JOIN ShopsGoodsRelation sgr ON s.id = sgr.shop_id JOIN yipinyoufudata.goods g ON g.id = sgr.goods_id WHERE g.id = #{goodsId}")
    Shops getGoodsShops(Object goodsId);

    @Select("SELECT GoodsScore.id, GoodsScore.scoreUserNameID, GoodsScore.goodsID, GoodsScore.scoreLevel, GoodsScore.scoreText, GoodsScore.createdTime, GoodsScore.updatedTime FROM GoodsScore JOIN User ON GoodsScore.scoreUserNameID = User.id WHERE GoodsScore.goodsID = #{goodsId};")
    List<GoodsComment> getGoodsComment(Object goodsId);


    @Select("SELECT * FROM GoodsScoreLabel WHERE goodsScoreId = #{id};")
    List<GoodsLabel> getGoodsLabel(int id);


    @Select("SELECT * FROM GoodsScoreImage WHERE goodsScoreId = #{id};")
    List<GoodsScoreImage> getGoodsCommentImage(int id);



}
